package com.dingding.queue.queue.producer;

import java.util.Properties;

import com.aliyun.openservices.ons.api.ONSFactory;
import com.aliyun.openservices.ons.api.Producer;
import com.aliyun.openservices.ons.api.PropertyKeyConst;
import com.dingding.common.core.config.Constants;
import com.dingding.common.core.config.MessageQueueConfig;

public class ProducerFactory {

	public  Producer producer = null;

	public void create() {

		Properties properties = new Properties();
		properties.put(PropertyKeyConst.ProducerId, MessageQueueConfig.getMESSAGE_QUEUE_PRODUCEID());// 您在控制台创建的Producer
		properties.put(PropertyKeyConst.AccessKey, Constants.MESSAGE_QUEUE_ACCESSKEY);
		properties.put(PropertyKeyConst.SecretKey, Constants.MESSAGE_QUEUE_SERECTKEY);
		if (producer == null) {
			producer = ONSFactory.createProducer(properties);
		}

		producer.start();

	}

}
